package com.primary.utils;

/**
 * @author Shen Jianhui
 * @time 2023/08/20 12:49 Sunday
 * @description In some string like phone or address, user often hope to hide them. In System,
 *              some information is necessary to get. For some information privately,this method
 *              will replace some characters in string.
 * @return
 */
public class StringReplaceUtils {
    public static String stringPhoneReplace(String phone){
        StringBuffer stringBuffer=new StringBuffer(phone);
        return stringBuffer.replace(3,7,"****").toString();
    }

    public static String stringAddressReplace(String address){
        StringBuffer stringBuffer=new StringBuffer(address);
        return stringBuffer.replace(2,address.length(),"*************").toString();
    }
    public static void main(String[] args) {
        System.out.println(stringPhoneReplace("13845678765"));
        System.out.println(stringAddressReplace("内蒙古自治区呼和浩特市"));
    }
}
